// 引入Vuex -----相当于咱们最大的仓库
import Vuex from 'vuex'
// 引入Vue
import Vue from 'vue'
// 导入模块
import home from './home'
import search from './search'
import detail from './detail'
import cart from './cart'
import user from './user'
import trade from './trade'
// state
import state from './state'
// 数据持久化存储的插件
import createPersistedState from 'vuex-persistedstate'
// 使用插件
Vue.use(Vuex)
export default new Vuex.Store({
  state,
  // 模块：把小仓库进行合并变为大仓库
  modules: {
    home,
    search,
    detail,
    cart,
    user,
    trade
  },
  plugins: [
    createPersistedState({
      storage: window.sessionStorage
    })
  ]
})
